package de.hibernate.example;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;

@Entity
@Table(name = "course")
public class Course {

	private int id;
	private String courseName;
	private List<EmployeeCourse> courses = new ArrayList<EmployeeCourse>();

	@Id
	@GenericGenerator(name = "generator", strategy = "increment")
    @GeneratedValue(generator = "generator")
	@Column(name = "course_id")
	public int getCourseId() {
		return id;
	}

	public void setCourseId(int courseId) {
		this.id = courseId;
	}

	@OneToMany(fetch=FetchType.LAZY,cascade=CascadeType.ALL,mappedBy="pk.course")
	public List<EmployeeCourse> getCourses() {
		return courses;
	}

	public void setCourses(List<EmployeeCourse> courses) {
		this.courses = courses;
	}

	public String getCourseName() {
		return courseName;
	}

	public void setCourseName(String courseName) {
		this.courseName = courseName;
	}

}
